package com.example.demo.controller;

import com.example.demo.common.Result;
import com.example.demo.entity.Message;
import com.example.demo.service.MessageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@RestController
public class MessageController {
    @Autowired
    private MessageService messageService;

    @GetMapping("/chatroom/{id}/message/")
    public Result getMessagesByChatRoomId(@PathVariable long id) {
        List<Map<String, Object>> messages = messageService.getMessagesByChatRoomId(id);
        return Result.success(messages);
    }
}
